feat: use warning and not exception to indicate no convergence#286
feat: use warning and not exception to indicate no convergence#286mortenengen wants to merge 9 commits intodevfrom
Conversation
talledodiego
left a comment
There was a problem hiding this comment.
The idea seems solid to me.
I tested it in a jupyter notebook and it seems to show correctly warnings each time.
We can probably extend this to other algorithms where we raise an exception for reaching the maximum number of iterations.
Would you like to explore the idea in other algorithms? You have more insight in the other methods on the |
Sure! I will work on this same PR. Hopefully during tonight's session |
|
@mortenengen finished here from my side. Up for your review. |
This is an experiment to use warnings instead of exceptions to indicate that an iterative solution does not reach convergence.
When no convergence is reached, it can be useful to return some calculation results to the user, so that these results can be examined, and measures can be implemented.
In the current implementation, no convergence is indicated by raising an exception, and therefore, no results are returned from the iterative solver. In this PR, a custom warning is shown instead, and the results at the time of the warning was shown are returned to the user.
To make sure that the warning is always shown, a custom filter is added. The user can always override this behavior, e.g. only showing it once, completely ignoring it, or even raising it as an error.